package com.kaibes.core.base.util;

import java.util.UUID;

public class UuidUtils {

    public static String getUUID(){
        return UUID.randomUUID().toString();
    }
    
    public static String getUUIDNoLine(){
        String s = UUID.randomUUID().toString();
        return s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23)
                + s.substring(24);
    }
    
    public static String toUUIDWithLine(String uuid) {
        byte[] bs = uuid.getBytes();
        byte[] bsT = new byte[bs.length+4];
        int j = 0;
        for (int i = 0; i < bs.length; i++) {
            if (i == 8 || i == 12 || i == 16 || i == 20) {
                bsT[j+i] = '-';
                j++;
            }
            bsT[j+i] = bs[i];
        }
        return new String(bsT);
    }
}
